import resources.Constants;

/* [start] 	initializes gui variables */
RegistNetPropertyBundle bundle = RegistNetPropertyBundle.getInstance("/resources/registnet");

String _student_records = bundle.getProperty("registnet.module.student_records.student_records");

String _student_number = bundle.getProperty("registnet.module.student_records.macro.student_records.search.student_number");
String _go = bundle.getProperty("registnet.module.student_records.macro.student_records.search.go");

String _personal_info = bundle.getProperty("registnet.module.student_records.macro.student_records.actions.info");
String _checklist = bundle.getProperty("registnet.module.student_records.macro.student_records.actions.checklist");
String _form5 = bundle.getProperty("registnet.module.student_records.macro.student_records.actions.form5");
String _curriculum = bundle.getProperty("registnet.module.student_records.macro.student_records.actions.curriculum");
String _transcript = bundle.getProperty("registnet.module.student_records.macro.student_records.actions.transcript");
/* [end] */



registnet.dao.Student DAOStudent;

/* [start]	searches for a student;
			displays the personal info of the student;
			notifies user if the student number entered found no match */
void searchStudent(String studentNumber){
	DAOStudent = new registnet.dao.StudentPeer().getStudent(studentNumber);
	if (DAOStudent != null){
		if (_user_type.equals(Constants.REGISTRAR)){
			showInfo();
			search_btn.focus();
		}
		else if (_user_type.equals(Constants.COLLEGE) && DAOStudent.getCurriculum().getDegreeCourse().getCollege().getCollegeCode().equals(_office)){			
			showInfo();
			search_btn.focus();
		}
		else{
			alert("Student not found");
		}
	}
	else{
		try{
			if (contents.getFirstChild() != null){
				contents.removeChild(contents.getFirstChild());
			}
			alert("Student not found");
		}catch(Exception e){ e.printStackTrace(); }
	}
}
/* [end] */



/* [start]	displays the personal info of the student */
void showInfo(){
	if (DAOStudent == null){
		alert("Student not found");
		return;
	}
	if (contents.getFirstChild() != null){
		contents.removeChild(contents.getFirstChild());
	}
	Component show_instance_form = Executions.createComponents("../../WEB-INF/macros/student_records/info.zul", contents, null);
	title.setValue(_personal_info);
}
/* [end] */



/* [start]	displays the form5 of the student */
void showForm5(){
	if (DAOStudent == null){
		alert("Student not found");
		return;
	}
	if (contents.getFirstChild() != null){
		contents.removeChild(contents.getFirstChild());
	}
	Component win = Executions.createComponents("../../WEB-INF/macros/student_records/form5.zul", contents, null);
	title.setValue(_form5);
}
/* [end] */



/* [start]	displays the curriculum of the student */
void showCurriculum(){	
	if (DAOStudent == null){
		alert("Student not found");
		return;
	}
	if (contents.getFirstChild() != null){
		contents.removeChild(contents.getFirstChild());
	}
	Component win = Executions.createComponents("../../WEB-INF/macros/student_records/curriculum.zul", contents, null);
	title.setValue(_curriculum);
}
/* [end] */



/* [start]	displays the transcript of the student */
void showTranscript(){
	if (DAOStudent == null){
		alert("Student not found");
		return;
	}
	if (contents.getFirstChild() != null){
		contents.removeChild(contents.getFirstChild());
	}
	Component win = Executions.createComponents("../../WEB-INF/macros/student_records/transcript.zul", contents, null);
	title.setValue(_transcript);
}
/* [end] */



/* [start]	displays the checklist of the student */
void showChecklist(){	
	if (DAOStudent == null){
		alert("Student not found");
		return;
	}
	if (contents.getFirstChild() != null){
		contents.removeChild(contents.getFirstChild());
	}
	Component show_instance_form = Executions.createComponents("../../WEB-INF/macros/student_records/checklist.zul", contents, null);
	title.setValue(_checklist);
	
}
/* [end] */
